import { CommonEntity } from '../../../../common/entities/common.entity';
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
import { DictType } from './dict-type.entity';

@Entity({
  name: 'sys_dict_item',
  comment: '系统字典项',
})
export class DictItem extends CommonEntity {
  @Column({ type: 'uuid', length: 36, comment: '字典类型Id' })
  typeId: string;

  @ManyToOne(() => DictType, (type) => type.items, {
    createForeignKeyConstraints: false,
  })
  @JoinColumn({ name: 'typeId' })
  type: DictType;

  @Column({ type: 'varchar', length: 50, comment: '字典项键名' })
  label: string;

  @Column({ type: 'varchar', length: 50, comment: '字典项值' })
  value: string;

  @Column({ type: 'int', default: 0, comment: '字典项排序' })
  order: number;

  @Column({ type: 'varchar', nullable: true, comment: '备注' })
  remark: string;
}
